﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using furapp.Model;
using Furion.DynamicApiController;
using Furion.UnifyResult;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SocketIOClient;
using SqlSugar;

namespace furapp.Controllers
{
    [DynamicApiController]
    public class UserController
    {
        private readonly ISqlSugarClient db; // 核心对象：拥有完整的SqlSugar全部功能
        public UserController(ISqlSugarClient sqlSugarClient) {
            this.db = sqlSugarClient;
        }

        public async Task<IActionResult> GetFirst(long id) {
            User user = await db.Queryable<User>().FirstAsync(u => u.Id == id);
            return new JsonResult(new RESTfulResult<object>
            {
                StatusCode = 200,
                Succeeded = true,
                Data = user,
                Errors = null,
                Extras = UnifyContext.Take(),
                Timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
            });
        }
    }
}
